<template>
	<view class="common-text">
		<u-checkbox-group @change="checkboxGroupChange" class="text">
			<u-checkbox class="check" shape="circle" @change="checkboxChange" v-model="item.checked"
				:label-disabled="false" v-for="(item, index) in list" :key="index" :name="item" :disabled="disabled">
				{{item.projectName}}&nbsp;&nbsp;&nbsp; {{item.jobId}}
			</u-checkbox>
		</u-checkbox-group>
		<view class="footerBtn" style="display: flex;">
			<view class="btn footerBtn footerBtns" style="justify-content: center;">
				<view style="padding:0 10px;width: 50%;">
					<button class="rightTabsBtn" type="primary" @click="commit">提交</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				disabled: "",
				list1: [],
				intersection: []
			};
		},
		mounted() {
			this.detail()
		},
		onLoad(option) {
			console.log(option)
			this.id = option.id
			this.list1.jobId = option.jobId
			this.list1.projectName = option.projectName
			console.log("任务单号[id]", this.list1.jobId)
			console.log("选择的任务单号[名称]", this.list1.projectName)
		},
		methods: {
			detail() {
				this.$api.jobList(res => {
					console.log(res)
					if (res.code === 200) {
						this.list = res.result || {}
						console.log(this.list)
						// if (this.list.projectName == this.list1.projectName) {
						// 	this.disabled = true
						// }
					}
				})
			},
			// 选中某个复选框时，由checkbox时触发
			checkboxChange(item) {
				console.log(item);
			},
			// 选中任一checkbox时，由checkbox-group触发
			checkboxGroupChange(item) {
				console.log(item);
				// this.jobId = item.name.jobId
				// this.projectName = item.name.projectName
				// console.log(this.jobId)
				// console.log(this.projectName)
				var arr = [],
					arrData = [];
				for (var item of item) {
					arr.push(item.projectName);
					arrData.push(item.jobId);
					this.selection = arr;
					this.selectionData = arrData;
					console.log(this.selection);
					console.log(this.selectionData);
				}
			},
			//提交
			commit() {
				wx.navigateTo({
					url: '/pages/claim/index?id=' + this.id + '&jobId=' + this.selectionData +
						'&projectName=' + this
						.selection,
				})
				console.log(222);
			}

		},
	};
</script>

<style>
	.common-text {}

	.check {
		display: flex;
		flex-direction: column;
		padding: 20rpx;
		background: #e1e5f9;
	}

	.footerBtn {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
	}

	.btn {
		border-radius: 0;
		width: 100%;
		background: #2f3a89;
	}

	.footerBtns {
		display: flex;
		background: #d2dcf8;
		padding: 10rpx 0;
		box-shadow: -1px 0 1px #ccc;
	}

	.rightTabsBtn {
		height: 60rpx;
		font-size: 14px;
		background: #2f3a89;
	}
</style>